package com.ushine.web.base.model.base;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.List;

/**
 * @Author: yls
 * @Date 2022/2/17 12:42
 * @Description: 树形表基础字段
 * @Version 1.0
 **/
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "树形表基础字段")
@MappedSuperclass
@Data
public class BaseTreeBO extends BaseBO implements Serializable {

    /**
     * 编号
     * // 解决前台js接收雪花id精度丢失问题
     * JsonFormat(shape = JsonFormat.Shape.STRING)
     */
    @Id
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty("编号")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @Column(name = "id", columnDefinition = "bigint comment '编号'")
    private Long id;


    /**
     * 父级id
     */
    @ApiModelProperty("父级id")
    @Column(name = "parent_id", columnDefinition = "bigint comment '父级id'")
    private Long parentId;


    /**
     * 非数据库字段
     */
    @Transient
    @ApiModelProperty("下级菜单")
    @TableField(exist = false)
    private List<? extends BaseTreeBO> children;

}
